// routes/uploadRoutes.js
const express = require('express');
const upload = require('../utils/fileUpload'); // 引入图片上传的中间件

const router = express.Router();

// 图片上传路由
router.post('/image', (req, res) => {
    upload(req, res, (err) => {
        if (err) {
            return res.status(400).json({ message: err.message });
        }
        // 返回上传成功后的文件路径
        res.json({ url: `/uploads/${req.file.filename}` });
    });
});

module.exports = router;
